package com.shardingsphere.modules.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shardingsphere.core.config.datasource.DataSource;
import com.shardingsphere.core.config.shardingsphere.DatasourceType;
import com.shardingsphere.modules.entity.Student;
import com.shardingsphere.modules.mapper.StudentMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService extends ServiceImpl<StudentMapper, Student> implements IService<Student> {

    @DataSource(DatasourceType.DB1)
    public List<Student> selectList() {
        return super.list();
    }

    @DataSource(DatasourceType.DB1)
    public List<Student> selectList(long pageIndex, long pageSize) {
        return super.page(new Page<>(pageIndex, pageSize)).getRecords();
    }

}
